<!DOCTYPE html>
<html>
    <head>
		<!--声明文档类型，设置文档字符集  -->
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
        <!--用于设置手机端的宽度，缩放，初始缩放比  -->
        <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0"></meta>
        <!-- 引入 Bootstrap -->
      	<link href="css/bootstrap.min.css" rel="stylesheet" media="screen"></link>
		<!-- 引入css -->
		<!-- <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> -->
		<link rel="stylesheet" href="css/style.css"></link>
		<!-- <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script> -->
       	
       	<!--引入jQuery  -->
       	<script src="js/jquery-1.7.2.min.js"></script>
        <title>信息技术研究所招新报名</title>

        <style>
			body{background:#D0D0D0;}
			body{
			/* background-image:url(images/registerBackGround.jpg); */ 
			background-repeat:no-repeat;background-position:center} 
												 }
			}
		</style>
<script type="text/javascript">
	/* 验证注册用户提交的数据 
	 * 
	 */
	function validate(){
		
		var str=$("#stuNo").val().replace(/(^\s*)|(\s*$)/g, '');
		if($("#username").val()==""||$("#username").val()==null){
			alert("亲，留下你的大名吧");
			$("#username").focus();
			return false;
		}
		else if($("#grade").val()==""||$("#grade").val()==null){
			alert("亲，专业还未填哦");
			$("#grade").focus();
			return false;
		}
		else if($("#stuNo").val()==""||$("#stuNo").val()==null){
			alert("亲，您还未填学号呢");
			$("#stuNo").focus();
			return false;
		}
		else if(isNaN(str)){
			alert("亲，只能输入数字");
			$("#stuNo").focus();
			return false;
		}else if(str.length!=9){
			alert("亲，请检查您的学号是否填写正确");
			$("#stuNo").focus();
			return false;
		}else if(str.substring(-1,4)!=2017){
			alert("亲，我们只招收新生哦,请检查您的学号!");
			$("#stuNo").focus();
			return false;
		}
		else if($("#telphone").val()==""||$("#telphone").val()==null){
			$("#telphone").focus();
			alert("亲，给个电话吧");
			return false;
		}
		else if($("#qq").val()==""||$("#qq").val()==null){
			alert("亲，要不要把QQ留下？");
			$("#qq").focus();
			return false;
		}
		else if($("input[name='sex']:checked").val()==null||$("input[name='sex']:checked").val()==""){
			alert("亲,性别还未选哦");
			return false;
		}
		else if($("input[name='role']:checked").val()==""||$("input[name='role']:checked").val()==null){
			alert("亲,选个方向吧");
			
			return false;
		}
		
		
		var dldata="";
		dldata={"username":$("#username").val(),"grade":$("#grade").val(),"telphone":$("#telphone").val(),"stuNo":$("#stuNo").val(),
		 "qq":$("#qq").val(),"intention":$("input[name='role']:checked").val(),"sex":$("input[name='sex']:checked").val()};
		var data1=JSON.stringify(dldata);
		$.ajax({
			type:"POST",
			contentType:"application/json",
			url:"userRegister",
			data:data1,
			dataType:"json",
		    success:function(data){
				if("2"==data.code){
					alert("您已经报过名了哦,修改方向可以点击修改哦");
				}
				if("10"==data.code){
					alert("亲，您的大名是不是输错了？");
				}
				if("11"==data.code){
					alert("亲，检查检查手机号吧");
				}
				if("-1"==data.code){
					alert("系统繁忙，请稍后再试");
				}
				if("0"==data.code){
					alert("恭喜你,报名成功!");
				}
			},
			error:function(data){
				alert("系统繁忙，请稍后再试");
			}
		  });	
	  }
	
		
</script>


<!--返回浏览记录的上一个页面  -->
<script type="text/javascript">
function back(){
	window.history.go(-1); 
    } 
</script> 
<!--链接更改页面  -->
<script type="text/javascript">
function update(){

	window.location.href="registerUpdate"; 
} 
</script>  
</head>
<body>
<div style="background-image:url(images/register4.jpg);height:100%;margin-top:-50px;" >
<div style="color:#F0F0F0;margin-top:50px;text-align:center;padding: 25px 0 0 0;">
<span style="font-size:30px;"><div style="margin-top:30px;">报名吧!</div></span>
</div>

<div style="margin-top:40px;text-align:center;">
<form  id="registerForm">
<div>
<input type="text" name="username" class="username" id="username" placeholder="姓名" >
</div>

<div>
<input type="text" name="grade" class="grade" id="grade" placeholder="专业" >
</div>

<div>
<input type="text" name="stuNo" class="stuNo" id="stuNo" placeholder="学号" >
</div>


<div>
<input type="text" name="telphone" class="telphone" id="telphone" placeholder="电话" />
</div>

<div>
<input type="text" name="qq" class="qq" id="qq" placeholder="QQ号码" id="qq"/>
</div>

<div style="margin-top:30px;">
<form id="sex">
<input name="sex" type="radio" value="男" id="student" style="width:30px;height:20px;"/>男&nbsp;&nbsp;&nbsp;&nbsp;
<input name="sex" type="radio" value="女" id="teacher" style="width:30px;height:20px;"/> 女
</form>
</div>

<div style="margin-top:30px;margin-left:-30px;">
<form id="intention" >
<input name="role" type="radio" value="Java Web" id="student" style="width:17px;height:17px;margin: 5px 5px 5px 19px;" />Java Web
<input name="role" type="radio" value="PHP" id="student" style="width:17px;height:17px;margin: 5px 5px 5px 22px" />PHP<br/>
<input name="role" type="radio" value="软件嵌入式" id="student" style="width:17px;height:17px;margin: 5px 10px" />软件嵌入式
<input name="role" type="radio" value="UI" id="student" style="width:17px;height:17px;margin: 5px 10px" />UI<br/>

<input name="role" type="radio" value="Android" id="manager"  style="width:17px;height:17px;margin: 5px 5px 0 15px;"/>	Android
<input name="role" type="radio" value="IOS" id="a"  style="width:17px;height:17px;margin: 5px 5px 0 28px"/>IOS<br/>
<input name="role" type="radio" value=" 硬件嵌入式" id="teacher" style="width:17px;height:17px;margin: 10px 5px 0 -48px"/> 硬件嵌入式
</form> 
</div>
</form>
</div>
<div style="margin-top:30px;margin-bottom:30px;">
<button type="button" class="btn btn-warning" id ="button"  value="报名" style="width:60px;height:40px;" onclick="validate();">报名</button>&nbsp;&nbsp;&nbsp;&nbsp;
<button type="button" class="btn btn-warning" id ="button"  value="修改"  style="width:60px;height:40px;" onclick="update();">修改</button>&nbsp;&nbsp;&nbsp;&nbsp;
<button type="button" class="btn btn-warning" id ="button"  value="返回" style="width:60px;height:40px;" onclick="back();">返回</button>
</div>
</div>
</body>
</html>